package com.rj.bd.admin.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.rj.bd.admin.entity.Admin;
import com.rj.bd.admin.entity.JiLu;
import com.rj.bd.covrersion.entity.Coversion;
import com.rj.bd.shop.entity.Shop;
import com.rj.bd.user.entity.User;


public interface AdminMapper{
	/**
	 * @desc admin的登录
	 * @param username
	 * @return
	 */
	@Select("SELECT * FROM admin WHERE username=#{username}")
	Admin selectByAdmin(String username);
	/**
	 * @desc 查询所有用户
	 * @return
	 */
	@Select("select * from user")
	List<User> findByUser();
	/**
	 * @desc 管理员查询兑换记录
	 * @return
	 */
	@Select("select * from shop")
	List<Shop> findByShop();
	/**
	 * @desc 管理员查询商品表
	 * @return
	 */
	@Select("SELECT * FROM conversion")
	List<Coversion> findCoversion();
	
	/***
	 * @desc 添加用户
	 * @param userId
	 * @param username
	 * @param password
	 * @param name
	 * @param sex
	 * @param tel
	 * @param money
	 * @param token
	 * @return
	 */
	@Insert("insert into user values(#{userId},#{username},#{password},#{name},#{sex},#{tel},#{money},#{token})")
	int addUser(@Param("userId")String userId, @Param("username")String username, @Param("password")String password, @Param("name")String name, @Param("sex")String sex, @Param("tel")String tel, @Param("money")String money,
			@Param("token")String token);
	
	/**
	 * @desc 查询记录
	 * @return
	 */
	@Select("SELECT user.username AS username,conversion.conName AS conname,shop.shopId AS shopid,shop.shopTime AS shoptime,shop.address AS shopaddress FROM shop,USER,conversion WHERE  shop.userId=user.userId AND shop.conId=conversion.conId")
	List<JiLu> queryShopJilu();
	
	/**
	 * @desc 修改用户积分
	 * @param money
	 * @return
	 */
	@Update("update user set money=#{money} where userId=#{userId}")
	int updatemoeny(@Param("money")String money, @Param("userId")String userId);
	
	/**
	 * @desc 添加用户
	 * @param user
	 * @return
	 */
	/*@Insert("insert into user(userId,username,password,name,sex,tel,money,token) VALUE (#{userId},#{username},#{password},#{name},#{sex},#{tel},#{money},#{token},)")
	Map<String, Object> addUser(User user);
	@Insert("insert into shop values(#{shopId},#{userId},#{conId},#{shopTime},#{address})")
	int importExcel(@Param("shopId")String shopId,@Param("userId")String userId,@Param("conId")String conId,@Param("shopTime")String shopTime,@Param("address")String address);
	*/
}
